#include "key.h"

static unsigned char Keynumber = 0;

unsigned char r_key(void)
{
	unsigned char keynumber = Keynumber;
	Keynumber = 0;
	return keynumber;
}

unsigned char key(void)
{
	unsigned char key_number = 0;
	if(0 == Key_1)
		key_number = 1;
	if(0 == Key_2)
		key_number = 2;
	if(0 == Key_3)
		key_number = 3;
	if(0 == Key_4)
		key_number = 4;
	return key_number;
}

void key_loop(void)
{
	static unsigned char last = 0;
	static unsigned char now = 0;
	last = now;
	now = key();
	if(!now && last)
		Keynumber = last;
}